function footForward(motor)
  foot(motor, 30, 90)
end

function footBackward(motor)
  foot(motor, -30, 90)
end

function foot(motor, speed, distance)
  resetRotationCount(motor)
  forward(motor, speed)
  repeat until abs(rotationCounts(motor)) > distance
  stop(motor)
end

function buttonFoot(motor)
  repeat
    if isPressed(LEFT) then
      forward(motor, 20)
    elseif isPressed(RIGHT) then
      backward(motor, 20)
    else
      stop(motor)
    end
  until isPressed(ESCAPE)
end

